#include <bits/stdc++.h>
using namespace std;
void quicksort(int left,int right,vector<int>& a)
{
    int i = 0,j=right;
    if(left>=right)
        return;
    int privot = a[left];
    while(i!=j)
    {
        while(a[j]>=privot&&i<j)
            j--;
        while(a[i]<=privot&&i<j)
            i++;
        if(i < j)
            swap(a[i],a[j]);
    }
    a[left] = a[i];
    a[i] = privot;
    quicksort(left,i-1,a);
    quicksort(i+1,right,a);
}
int main()
{
    vector<int> a = {1,6,8,4,3,2,7};
    int left = 0,right = a.size()-1;
    quicksort(left,right,a);
    for(auto i:a)
        cout<<i<<" ";
}
